package itheima02;


import utils.JDBCUtil;

import java.sql.*;
import java.util.Scanner;

/**
 * @author xxx
 * @date 2021/1/3 21:56
 * @description
 */
public class Test {
    public static void main(String[] args) throws SQLException {
        //输入用户名
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入用户:");
        String uname=scanner.nextLine();




        //输入密码
        Scanner scanner1=new Scanner(System.in);
        System.out.println("请输入密码:");
        String upass=scanner1.nextLine();
        //用工具类连接数据库


        Connection connection=JDBCUtil.getConnection();
        Statement statement=connection.createStatement();
        //设置sql语句
        String sql="select * from  users where uname='"+uname+"' and upass='"+upass+"'";

        //获取sql对象
        ResultSet resultSet =statement.executeQuery(sql);
        //设置处理结果
        if(resultSet.next()){
            System.out.println("登陆成功");
        }else {
            System.out.println("登陆失败");
        }
        //关闭资源
         JDBCUtil.release(connection,statement,resultSet);
    }
}
